<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="店铺id">
              <a-input  v-model="queryParam.storeId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="产品Id">
              <a-input  v-model="queryParam.productId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleInit" type="primary" icon="plus">初始化库存</a-button>

    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">


      </a-table>
    </div>
    <!-- table区域-end -->

  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction, postAction} from "@api/manage";

export default {
  name: "StmStoreProductStockList",
  mixins: [JeecgListMixin],
  components: {},
  data() {
    return {
      description: '门店商品库存表管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '店铺id',
          align: "center",
          dataIndex: 'storeId'
        },
        {
          title: '产品Id',
          align: "center",
          dataIndex: 'productId'
        },
        {
          title: '产品名称',
          align: "center",
          dataIndex: 'productName'
        },

        {
          title: '规格',
          align: "center",
          dataIndex: 'productSpec'
        },
        {
          title: '下单总数量',
          align: "center",
          dataIndex: 'productQty'
        },
        {
          title: '库存',
          align: "center",
          dataIndex: 'stock'
        },
      ],
      url: {
        list: "/stm/stmStoreProductStock/list",
        init: "/stm/stmStoreProductStock/init",
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {

    handleInit() {
      getAction(this.url.init, {}).then((res) => {
        if (res.success) {
          this.$message.success(res.message);
          this.loadData(1)
        } else {
          this.$message.warning(res.message);
        }
      })

    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>